My first online map
# Earthquakes
eq <- st_read("https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_day.geojson")
## Reading layer `2.5_day' from data source
## `https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_day.geojson'
## using driver `GeoJSON'
## Simple feature collection with 45 features and 27 fields
## Geometry type: POINT
## Dimension: XYZ
## Bounding box: xmin: -178.3589 ymin: -22.4227 xmax: 176.6326 ymax: 66.055
## z_range: zmin: 4.6 zmax: 526.354
## Geodetic CRS: WGS 84
# Fault lines
faults <- esri2sf::esri2sf(
"https://services.arcgis.com/jIL9msH9OI208GCb/ArcGIS/rest/services/Active_Faults/FeatureServer/0",
where = "1=1") %>%
st_transform(target_crs)
## Layer Type: Feature Layer
## Geometry Type: esriGeometryPolyline
## Service Coordinate Reference System: 4326
## Output Coordinate Reference System: 4326
# Map
leaflet() %>%
setView(lng = 63, lat = 28, zoom = 2) %>%
addProviderTiles(providers$CartoDB.DarkMatter, group = "Carto") %>%
addProviderTiles(providers$Esri.WorldImagery, group = "Satellite") %>%
addPolylines(
data = faults,
color = "orange",
weight = 2,
popup = ~paste("Name:", name),
group = "Faults") %>%
addCircleMarkers(
data = eq,
color = "red",
fillOpacity = 1,
radius = ~mag,
popup = ~paste("Location:", place, "<br>",
"Magnitude:", mag, "<br>",
"Date:", as.character(as.POSIXct(time/1000, origin="1970-01-01"))),
group = "Earthquakes") %>%
addLayersControl(
baseGroups = c("Carto","Satellite"),
overlayGroups = c("Earthquakes", "Faults"),
options = layersControlOptions(collapsed = FALSE)) %>%
addLegend(
position = "bottomright",
colors = c("red", "orange"),
labels = c("Circle size proportional to magnitude", "Fault lines"),
opacity = 1) %>%
addResetMapButton() %>%
addFullscreenControl()